{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id = Section1> </a>\n",
    "# 连续函数的运算和初等函数的连续性\n",
    "## 初等函数的连续性\n",
    "### 前面证明了三角函数及反三角函数在它们的定义域内是连续的.我们指出(但不详细讨论),指数函数a*(a>0,a≠1)对于一切实数x都有定义,且在区间(-∞,+∞)内是单调的和连续的,它的值域为(0,+∞).由指数函数的单调性和连续性,引用定理2可得:对数函数logx(a>0,a≠1)在区间(0.+)内单调且连续.幂函数y=x“的定义域随μ的值而异,但无论为何值,在区间(0,+∞)内幂函数总是有定义的.下面我们来证明,在(0,+∞)内幂函数是连续的事实上,设x>0 则\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y = x ^ {\\mu} = a ^ {\\mu \\log_a x}\n"
     ]
    }
   ],
   "source": [
    "formula = \"y = x ^ {\\\\mu} = a ^ {\\\\mu \\\\log_a x}\"\n",
    "print(formula)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id = Section1> </a>\n",
    "### 因此,幂函数x“可看作是由y=a“,u=mlog。x复合而成的,由此,根据定理4,它在(0,+∞)内连续.如果对于μ取各种不同值加以分别讨论,可以证明(证明从略)幂函数在它的定义域内是连续的.综合起来得到:本初等函数在它们的定义域内都是连续的.最后,根据第一节中关于初等函数的定义,由基本初等函数的连续性以及本节定理1、定理4可得下列重要结论:一切初等函数在其定义区间内都是连续的.所谓定义区间,包含在定义域内的区间.根据函数f(x)在点x连续的定义,如果已知f(x)在点连续,那么求f(x)当x→x的极限时,只要求f（x）在点x的函数值就行了,因此,上述关于初等函数连续性的结论提供了求极限的一个方法,这就是:如果f(x)是初等函数，且x是f(x)的定义区间内的点,那么\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Limit of f(x) as x approaches x0: sin(x0)\n",
      "Value of f(x0): sin(x0)\n",
      "Is the function continuous at x0? True\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义符号变量\n",
    "x = sp.Symbol('x')\n",
    "x0 = sp.Symbol('x0')\n",
    "\n",
    "# 定义函数f(x)\n",
    "def f(x):\n",
    "    return sp.sin(x)  # 修改为正弦函数\n",
    "\n",
    "# 计算极限\n",
    "limit_result = sp.limit(f(x), x, x0)\n",
    "\n",
    "# 检查函数在x0处的值\n",
    "function_value_at_x0 = f(x0)\n",
    "\n",
    "# 检查极限是否等于函数值\n",
    "is_continuous = (limit_result == function_value_at_x0)\n",
    "\n",
    "print(f\"Limit of f(x) as x approaches x0: {limit_result}\")\n",
    "print(f\"Value of f(x0): {function_value_at_x0}\")\n",
    "print(f\"Is the function continuous at x0? {is_continuous}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "oo*sign(log(a))\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义符号变量\n",
    "x = sp.Symbol('x')\n",
    "a = sp.Symbol('a')\n",
    "\n",
    "# 定义函数\n",
    "f = sp.log(a,1 + x)/x\n",
    "\n",
    "# 求极限\n",
    "limit_result = sp.limit(f,x,0)\n",
    "print(limit_result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "log(a)\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义符号变量\n",
    "x = sp.Symbol('x')\n",
    "a = sp.Symbol('a')\n",
    "\n",
    "# 定义函数表达式\n",
    "f = (a ** x - 1) / x\n",
    "\n",
    "# 求极限\n",
    "result = sp.limit(f, x, 0)\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义符号变量\n",
    "x = sp.Symbol('x')\n",
    "alpha = sp.Symbol('alpha')\n",
    "\n",
    "# 定义函数表达式\n",
    "f = ((1 + x) ** alpha - 1) / x\n",
    "\n",
    "# 求极限\n",
    "result = sp.limit(f, x, 0)\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "exp(6)\n"
     ]
    }
   ],
   "source": [
    "import sympy as sp\n",
    "\n",
    "# 定义符号变量\n",
    "x = sp.Symbol('x')\n",
    "\n",
    "# 定义函数表达式\n",
    "f = (1 + 2 * x) ** (3 / sp.sin(x))\n",
    "\n",
    "# 求极限\n",
    "result = sp.limit(f, x, 0)\n",
    "print(result)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
